#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <ucontext.h>
#include <assert.h>

#include "backtracer.h"
#include "backtracer_linux.h"
#include "backtracer_linux_arm.h"

//------------------------------------------------------------------------------

TBGError SetSigSegvHandling(func_map *pmap) {
    TBGError ret = 0;
    CHECK_DBG_ERR(pmap, NULL_PTR);
    _SigHandlerGetSetFuncMap(pmap);

    struct sigaction sa;
    sa.sa_flags = SA_SIGINFO;
    sigemptyset(&sa.sa_mask);
    sa.sa_sigaction = _SigSegvHandler;

    CHECK_RET(sigaction(SIGSEGV, &sa, NULL) != -1, CANNOT_SET_SIGHANDLER,
              exit_point, ret);
exit_point:
    return ret;
}

//------------------------------------------------------------------------------

void TestFail() {
//    printf("\nGood bue! I'll fail your programm just now;)\n");
    int a = *(int *)(-1);
    printf("%d", a);
}


